package org.gruposp2p.proyectokarma.service

import org.gruposp2p.proyectokarma.domain.CometdChannel;
import org.springframework.transaction.annotation.Transactional;

class CometdChannelService 
    implements org.gruposp2p.cometd.CometdChannelService {

    boolean transactional = true

    @Transactional(readOnly = true)
    List<CometdChannel> listData() {
        log.debug "CometdChannel.list().getClass(): " + CometdChannel.list().getClass()
        List<CometdChannel> channels = CometdChannel.list()
        return channels
    }

    void insertData () {
            def shortDescription1 = "shortDescription1shortDescription1shortDescription1"
            def longDescription1 = "longDescription1longDescription1longDescription1longDescription1"
            Date dateAdded1 = new Date()
            def cometdChannel1 = new CometdChannel(channelId:"/service/group/**",
                methodName:"handleGroupMessage", shortDescription:shortDescription1,
                longDescription:longDescription1, dateAdded:dateAdded1)
            cometdChannel1.save(flush: true)

            def shortDescription2 = "shortDescription2shortDescription2shortDescription2"
            def longDescription2 = "longDescription2longDescription2longDescription2longDescription2"
            Date dateAdded2 = new Date()
            def cometdChannel2 = new CometdChannel(channelId:"/service/alert",
                methodName:"handleAlert", shortDescription:shortDescription2,
                longDescription:longDescription2, dateAdded:dateAdded2)
            cometdChannel2.save(flush: true)
    }

    void insertPeers () {
        
    }

}

